#!/bin/sh
# Server-side demuxing by default

source /etc/device_config

case "$1" in
	start)
		echo -n "Starting dhcpd Daemon & httpd Server: "
		start-stop-daemon -S -q -p /var/run/udhcpd.pid -x /usr/sbin/udhcpd -- $UDHCPD_CONF
		httpd -h /www
		[ $? = 0 ] && echo "OK" || echo "FAIL"
		;;

	stop)
		echo -n "Stopping dhcpd Daemon & httpd Server: "
		killall -7 httpd
		start-stop-daemon -K -q -p /var/run/udhcpd.pid 2>/dev/null
		[ $? = 0 ] && echo "OK" || echo "FAIL"
		;;

	restart)
		$0 stop
		sleep 1
		$0 start
		;;

	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac
